package pers.zc.activiti.thread;

import org.springframework.stereotype.Service;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @description 测试curerntHashMap  存储共享变量
 * @Author Lin FuYuan
 * @date 2020/1/15
 */
@Service
public class CurrentHashMapTest {
        private static CurrentHashMapTest test = new CurrentHashMapTest();
        private CurrentHashMapTest(){
        }
        public static CurrentHashMapTest getInstance(){
            if (test == null) {
                test = new CurrentHashMapTest();
            }
            return test;
        }
        //使其线程可见
        private static volatile ConcurrentHashMap<String,Entity> map = new ConcurrentHashMap<>(16);
        public void setMap(String key,Entity value){
            map.put(key,value);
        }
        public Entity getMap(String key){
            return map.get(key);
        }

}
